package com.shopping.index;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.opensymphony.xwork2.ActionContext;
import com.shopping.orm.CommodityDao;
import com.shopping.orm.LinkDao;
import com.shopping.orm.NewsDao;
import com.shopping.orm.Sort;
import com.shopping.orm.SortDao;
import com.shopping.orm.Type;
import com.shopping.orm.TypeDao;



public class SortListImpl implements SortList {

	private SortDao sortDao;
	private TypeDao typeDao;
	private NewsDao newsDao;
	private LinkDao linkDao;
	private CommodityDao commodityDao;
	private Sort sort;
	private Type type;
	private List typeList;
	private List sortList;
	private List newsList;
	private List cList;
	private List newCommodityList;
	private List hotList;
	private List linkList;
	private String typeId;
	private List sList;
	
	public String execute() throws Exception{
			//商品类别List
			typeList = typeDao.findAll();
			setTypeList(typeList);
			Iterator iterator = typeList.iterator();
			Type t =(Type) iterator.next();
			iterator.next();
			Set set = t.getSorts();
			setSortList(sortList);
			
			//网站公告List
			newsList = newsDao.findAll();
			setNewsList(newsList);
			
			//特价商品
			cList = commodityDao.findByproperty("identifier", "特价商品");
//			System.out.println(cList);
			setCList(cList);
			//热卖商品
			 hotList = commodityDao.findByproperty("identifier", "热卖商品");
			 //友情链接
			 linkList = linkDao.findAll();
		
			
			//最新商品
			newCommodityList = commodityDao.findByproperty("identifier", "最新商品");
			setNewCommodityList(newCommodityList);
		return "success";	
	}
	
	/**
	 * 根据TYPEID获取sort
	 * @param:typeid
	 * 
	 */
	public List getSort(){
	
		return sList;
	}
	public String showNews(){
		try{
			List newsList = newsDao.findAll();
			setNewsList(newsList);
		}catch(Exception e){
			e.printStackTrace();
		}
		return "success";
	}

	public SortDao getSortDao() {
		return sortDao;
	}

	public void setSortDao(SortDao sortDao) {
		this.sortDao = sortDao;
	}

	public TypeDao getTypeDao() {
		return typeDao;
	}

	public void setTypeDao(TypeDao typeDao) {
		this.typeDao = typeDao;
	}

	public NewsDao getNewsDao() {
		return newsDao;
	}

	public void setNewsDao(NewsDao newsDao) {
		this.newsDao = newsDao;
	}

	public LinkDao getLinkDao() {
		return linkDao;
	}

	public void setLinkDao(LinkDao linkDao) {
		this.linkDao = linkDao;
	}

	public CommodityDao getCommodityDao() {
		return commodityDao;
	}

	public void setCommodityDao(CommodityDao commodityDao) {
		this.commodityDao = commodityDao;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public List getTypeList() {
		return typeList;
	}

	public void setTypeList(List typeList) {
		this.typeList = typeList;
	}

	public List getSortList() {
		return sortList;
	}

	public void setSortList(List sortList) {
		this.sortList = sortList;
	}

	public List getNewsList() {
		return newsList;
	}

	public void setNewsList(List newsList) {
		this.newsList = newsList;
	}

	public List getCList() {
		return cList;
	}

	public void setCList(List list) {
		cList = list;
	}

	public List getNewCommodityList() {
		return newCommodityList;
	}

	public void setNewCommodityList(List newCommodityList) {
		this.newCommodityList = newCommodityList;
	}

	public List getHotList() {
		return hotList;
	}

	public void setHotList(List hotList) {
		this.hotList = hotList;
	}

	public List getLinkList() {
		return linkList;
	}

	public void setLinkList(List linkList) {
		this.linkList = linkList;
	}

	public String getTypeId() {
		return typeId;
	}

	public void setTypeId(String typeId) {
		this.typeId = typeId;
	}

	public List getSList() {
		return sList;
	}

	public void setSList(List list) {
		sList = list;
	}

	public void setSort(Sort sort) {
		this.sort = sort;
	}
	
	

	

}
